/* ----------------------------------------------------------------------------
* File: main.cpp
*
* Desc: Main function
*
* Created: 20/12/2010, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#include "main.h"


int _tmain(int argc, _TCHAR* argv[])
{
	
	if (argc == 1)
	{
		SERVICE_TABLE_ENTRY ServiceTable[1];
		ServiceTable[0].lpServiceName = TEXT("Skype Plugin");
		ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;

		if (!StartServiceCtrlDispatcher(ServiceTable))
			exit(EXIT_FAILURE);
	}
	else if (wcscmp(argv[argc - 1], TEXT("install")) == 0)
		InstallWinService(argv[0]);
	else if (wcscmp(argv[argc - 1], TEXT("remove")) == 0)
		RemoveWinService(argv[0]);
	else if (wcscmp(argv[argc - 1], TEXT("start")) == 0)
		StartWinService(argv[0]);
	else if (wcscmp(argv[argc - 1], TEXT("stop")) == 0)
		StopWinService(argv[0]);

	exit(EXIT_SUCCESS);
}